<template>
  <a-modal
    title="医生删除"
    :open="open"
    :centered="true"
    ok-text="注册"
    cancel-text="取消"
    :mask-closable="false"
    @ok="handleOk"
    @cancel="handleCancel"
  >
    <a-form
      :model="model"
      :label-col="{ span: 5 }"
      :wrapper-col="{ span: 16 }"
      :rules="rules"
    >
<!--      <a-form-item-->
<!--        name="name"-->
<!--      >-->
<!--        <template #label>-->
<!--          <span class="text-[18px]">姓名</span>-->
<!--        </template>-->
<!--        <a-input v-model:value="model.name" placeholder="请输入姓名"/>-->
<!--      </a-form-item>-->
      <a-form-item
        name="card_number"
      >
        <template #label>
          <span class="text-[18px]">账号</span>
        </template>
        <a-input v-model:value="model.card_number" placeholder="请输入账号"/>
      </a-form-item>
      <a-form-item
        name="passwd"
      >
        <template #label>
          <span class="text-[18px]">密码</span>
        </template>
        <a-input-password v-model:value="model.passwd" placeholder="请输入密码"/>
      </a-form-item>
    </a-form>

  </a-modal>
</template>

<script>
import {reactive, ref} from "vue";
import axios from "axios";
import API_BASE_URL from "../../config";
import {message} from "ant-design-vue";

export default {
  name: "DoctorDelete",
  setup(props, {emit}) {
    const open = ref(false)

    const model = reactive({
      name: '',
      card_number: '',
      passwd: ''
    })

    const rules = reactive({
      name: [
        {
          required: true,
          message: '请输入姓名',
          trigger: 'blur'
        }
      ],
      card_number: [
        {
          required: true,
          message: '请输入要删除账号',
          trigger: 'blur'
        }
      ],
      passwd: [
        {
          required: true,
          message: '请输入要删除账号的密码',
          trigger: 'blur'
        }
      ]
    })


    const showModal = () => {
      open.value = true
    }
    const handleCancel = () => {
      open.value = false
      //清空输入
      model.name = ''
      model.card_number = ''
      model.passwd = ''
    }
    const handleOk = () => {
      // let formData = new FormData()
      // formData.append('name', model.name)
      // formData.append('card_number', model.card_number)
      // formData.append('passwd', model.passwd)
      //
      // axios.post(`${API_BASE_URL}/doctor/add`, formData).then((res) => {
      //   if (res.data.code === 0) {
      //     message.success('注册成功')
      //   }
      //   if (res.data.code === 1002){
      //     message.error('账号已存在')
      //   }
      // })

      //清空输入
      model.name = ''
      model.card_number = ''
      model.passwd = ''

      open.value = false

    }

    return {
      open,
      model,
      handleCancel,
      handleOk,
      showModal,
      rules

    }
  }
}
</script>

<style scoped>

</style>
